<?php
/**
 * Created by PhpStorm.
 * User: YongXuan.Huang
 * Date: 2017/4/23
 * Time: 17:24
 */

namespace AppVue\Http\Models;


class ResponseResult
{
    static function success($obj)
    {
        return self::message(0, $obj, true);
    }

    static function error(int $code, $obj)
    {
        return self::message($code, $obj);
    }

    private static function message(int $code, $obj, bool $success = false)
    {
        $result = array();
        $result['code'] = $code;
        $result['success'] = $success;
        $result['data'] = $obj;
        return json_encode($result);
    }
}